package com.zhihong.controller;

import com.zhihong.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName BlogController
 * @Author 庄志宏
 * @Date 2022/8/31 12:36
 */
@RestController
public class BlogController {

    /**
     * 导出csv文件
     *
     * @param response
     * @throws Exception
     */
    @Autowired
    private BlogService blogService;
    @GetMapping("/getExport")
    public void getExport(HttpServletResponse response) throws Exception {
        long start = System.currentTimeMillis();
        blogService.export(response);
        long end = System.currentTimeMillis();
        System.out.println("爬取所有文章一共花费了多少" + (end-start) + "毫秒");
    }

}
